package com.example.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.service.dao.TestDao;
import com.example.service.model.Test;
import com.example.service.service.TestService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class TestServiceImpl implements TestService {
    @Autowired
    private TestDao testDao;
    @Override
    public void insert(Test test) {
        testDao.insert(test);
    }

    @Override
    public List<Test> query(Test test) {
        return testDao.selectList(new QueryWrapper<Test>().eq(!StringUtils.isEmpty(test.getName()), "name", test.getName())
                .eq(test.getId() != null, "id", test.getId()));
    }

    @Override
    public Test selectById(Test test) {
        return testDao.selectByXml(test.getId());
    }
}
